﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Web;

namespace Lilium.Web.Mvc.AjaxControlToolkit
{
	public class ServicePathConverter: StringConverter
	{
		public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
		{
			if (destinationType == typeof(string))
			{
				string strValue = (string)value;

				if (string.IsNullOrEmpty(strValue))
				{
					HttpContext currentContext = HttpContext.Current;

					if (currentContext != null)
					{
						return currentContext.Request.FilePath;
					}
				}
			}

			return base.ConvertTo(context, culture, value, destinationType);
		}
	}
}